/*
 * @Author: wang cong wangc9832@163.com
 * @Date: 2023-05-10 10:16:11
 * @LastEditors: wang cong wangc9832@163.com
 * @LastEditTime: 2023-06-16 15:55:56
 * @FilePath: /ams-front/src/api/asset/amsAssetManage.ts
 * @Description:
 *
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
 */
import { BasicFetchResult } from '../model/baseModel';
import { defHttp } from '@/utils/http/axios';
import { downloadBlob } from '@/utils/file/download';
const api = '/amsAsset';
// 销售资产_分页查询

export const salePage = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/page/sale', params });
// 资产查单条
export const getDetail = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/detail', params });
/**
 * 查询资产管理分页
 * @author 1
 * @date 2023-05-10 09:44:35
 */
export const page = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/page', params });
export const assetList = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/list', params });
/**
 * 添加资产管理
 * @author 1
 * @date 2023-05-10 09:44:35
 */
export const add = (params?: any) =>
  defHttp.post({ url: api + '/add', params });
/**
 * 修改资产管理
 * @author 1
 * @date 2023-05-10 09:44:35
 */
export const edit = (params?: any) =>
  defHttp.post({ url: api + '/edit', params });

/**
 * 删除资产管理
 * @author 1
 * @date 2023-05-10 09:44:35
 */
export const del = (ids: string[]) =>
  defHttp.post({ url: api + '/delete', params: ids });
/**
 * 导出资产管理
 * @author 1
 * @date 2023-05-10 09:44:35
 */
export const exp = (params?: any) => {
  return new Promise<void>((resolve, reject) => {
    defHttp
      .get(
        { responseType: 'blob', url: api + '/export', params },
        { isReturnNativeResponse: true }
      )
      .then((res) => {
        downloadBlob(res);
        resolve();
      })
      .catch(() => {
        reject();
      });
  });
};

export const audit = (id: string, isPass: string, bpmRemark: string) => {
  return defHttp.post({ url: api + '/audit', params: { id, isPass, bpmRemark } });
}

export const abandon = (id: string) => {
  return defHttp.post({ url: `${api}/abandon/${id}` });
}